package leetcode.题库.二叉树;

import leetcode.题库.pubclass.TreeNode;

/**
 * 对称二叉树
 *
 * @author yanzhenming
 * @date 2023/4/16  2:44
 */
public class Solution101 {
    public boolean isSymmetric(TreeNode root) {
        if (root == null) return true;
        return isSymmetric(root.left, root.right);
    }
    public boolean isSymmetric(TreeNode left, TreeNode right) {
        if (left == null && right == null) return true;
        if (left == null || right == null) return false;
        if (left.val != right.val) return false;
        return isSymmetric(left.left, right.right)
                && isSymmetric(left.right, right.left);
    }
}
